﻿function openForm(action, id, baseInfoType) {
    if (!baseInfoType) {
        baseInfoType = "DW";
    }
    var result = window.open("BaseInfoForm.aspx?id=" + id + "&action=" + action + "&baseInfoType=" + baseInfoType);
    if (result == "ok") {
        window.location.reload();
    }
}

function deleteConfirm() {
    if (confirm('确定要删除该条记录？')) {
        return true;
    }
    return false;
}

function listSearch() {
    $(ClientIds.btnSearch)[0].click();
}

//服务端控件ID获取
var ClientIds = getClientIds();

function uploadTemplate() {

    var template = "";
    if (formType == 'GR')
        template = "/Resources/Templates/基本信息导入模板-个人.xls";
    else {
        template = "/Resources/Templates/基本信息导入模板-单位或个体户.xls";
    }

    var fileInfo = OpenFileUploaderWithFile("批量导入模板", template);
//    var fileInfo = 'file;file';

    if (fileInfo) {
        jQuery.ajax({
            url: "/Common/Services/BaseInfoFormHandler.aspx",
            type: "POST",
            dataType: "text",
            data: {
                method: 'UploadBaseInfos',
                file: fileInfo,
                formType: formType
            },
            success: function (data) {
                var resultParam = data.split(';');
                //alert(resultParam[0]);
                
                if (resultParam.length > 1) {
                    var result = window.showModalDialog("BaseInfoImportConfirm.aspx?batchId=" + resultParam[1] + "&t=" + new Date().getTime(), null, "dialogheight: 650px; dialogwidth: 900px; dialogtop: px; dialogleft: px; edge:raised; center: yes; help: yes; resizable: yes; status: no;");
                    if (result === 'ok') {
                        listSearch();
                    }
                } else {
                    $("#messageContent").html(resultParam[0]);
                    $('#returnMessage').dialog('open');
                }
            },
            error: function (xmlHttpRequest, textStatus, errorThrown) {
                alert('系统错误 status:' + xmlHttpRequest.status + ' readyState:' + xmlHttpRequest.readyState + ' textStatus:' + textStatus);
            }
        });
    }
}

function exportData() {
    $(ClientIds.exportBtn)[0].click();
}